home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Apple Macintosh Developer Technical Support
- **
- ** File: TRootObj.c
- ** Written by: Eric Soldan
- **
- ** Copyright © 1992 Apple Computer, Inc.
- ** All rights reserved.
- */
-
- /* You may incorporate this sample code into your applications without
- ** restriction, though the sample code has been provided "AS IS" and the
- ** responsibility for its operation is 100% yours. However, what you are
- ** not permitted to do is to redistribute the source as "DSC Sample Code"
- ** after having made changes. If you're going to re-distribute the source,
- ** we require that you make it clear in the source that the code was
- ** descended from Apple Sample Code, but that you've made changes. */
-
- /* See the files "=How to write your app" and "=Using TreeObj.c" for information
- ** on this function. */
-
- /* This file isn't really used for much here. The whole hierarchical document usage of
- ** AppWannabe is very limited. This file is here so that AppWannabe can be converted
- ** into an application that does use the hierarchical document architecture. AppWannabe
- ** is all set up to start using it. This is convenient, as it allows there to be an
- ** initial document type. */
-
-
-
- /*****************************************************************************/
-
-
-
- #include "App.h" /* Get the application includes/typedefs, etc. */
- #include "App.protos.h" /* Get the prototypes for application. */
-
- #ifndef __OSEVENTS__
- #include <OSEvents.h>
- #endif
-
- #ifndef __OSUTILS__
- #include <OSUtils.h>
- #endif
-
- #ifndef __QUICKDRAW__
- #include <Quickdraw.h>
- #endif
-
- #ifndef __UTILITIES__
- #include "Utilities.h"
- #endif
-
-
-
- #pragma segment DrawObjects
- long TRootObj(TreeObjHndl hndl, short message, long data)
- {
- short fileRefNum;
- OSErr err;
- #if VH_VERSION
- char *cptr;
- #endif
-
- switch (message) {
- case INITMESSAGE:
- mDerefRoot(hndl)->timeControl[0] = 5 * 60 * 60;
- mDerefRoot(hndl)->timeControl[1] = 0;
- mDerefRoot(hndl)->timeControl[2] = 0;
- mDerefRoot(hndl)->timeControl[3] = 5 * 60 * 60;
- mDerefRoot(hndl)->timeControl[4] = 0;
- mDerefRoot(hndl)->timeControl[5] = 0;
- mDerefRoot(hndl)->numMovesInTimeControl[0] = 0;
- mDerefRoot(hndl)->numMovesInTimeControl[1] = 0;
- mDerefRoot(hndl)->numMovesInTimeControl[2] = 0;
- mDerefRoot(hndl)->timeRemaining[0] = mDerefRoot(hndl)->timeControl[0];
- mDerefRoot(hndl)->timeRemaining[1] = mDerefRoot(hndl)->timeControl[0];
- mDerefRoot(hndl)->numMoves[0] = 0;
- mDerefRoot(hndl)->numMoves[1] = 0;
- mDerefRoot(hndl)->rightStart = -1;
- /* •••• Initialize the new object to default values. Note that the
- ** values are pre-initialized to 0 before this is called. I
- ** am setting some fields to zero anyway for completeness and
- ** readability. */
- break;
-
- case FREADMESSAGE:
- fileRefNum = data;
- err = ReadTreeObjData(hndl, fileRefNum);
- mDerefRoot(hndl)->rightStart = -1;
- return(err);
- break;
-
- case FWRITEMESSAGE:
- fileRefNum = data;
- return(WriteTreeObjData(hndl, fileRefNum));
- break;
-
- case HREADMESSAGE:
- return(HReadTreeObjData(hndl, (Handle)data));
- break;
-
- case HWRITEMESSAGE:
- return(HWriteTreeObjData(hndl, (Handle)data));
- break;
-
- case VHMESSAGE:
- #if VH_VERSION
- cptr = ((VHFormatDataPtr)data)->data;
- ccatchr(cptr, 13, 2);
- VHRootInfo(hndl, cptr);
- ccatchr(cptr, 13, 2);
- VHFileRecInfo(hndl, cptr);
- return(true);
- #endif
- break;
-
- default:
- break;
- }
-
- return(noErr);
- }
-
-
-
-